home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / centerguide < prev    next >
Encoding:
Text File  |  2000-05-21  |  865 b   |  42 lines

  1. #!/usr/app/bin/perl
  2.  
  3. eval 'exec /usr/app/bin/perl  -S $0 ${1+"$@"}'
  4.     if 0; # not running under some shell
  5.  
  6. use Gimp qw(:auto __ N_);
  7. use Gimp::Fu;
  8.  
  9. register    "center_guide",
  10.         "Creates h- & v-guides at the center of the image.",
  11.         "Physical center = width/2 and height/2; Optical center = the Golden Mean.",
  12.         "Claes G Lindblad <claesg\@algonet.se>",
  13.         "Claes G Lindblad",
  14.         "990323",
  15.         N_"<Image>/Guides/Center Guide...",
  16.         "*",
  17.         [
  18.         [PF_RADIO,
  19.             "center",
  20.             "center",
  21.              0,
  22.             [Physical => 0, Optical => 1]
  23.         ]
  24.         ],
  25.     sub {
  26.         my ($img, $layer, $center) = @_;
  27.  
  28.         $w = $img->width();
  29.         $h = $img->height();
  30.         $hc = int($h/2 + 0.5);
  31.         $vc = int($w/2 + 0.5);
  32.  
  33.         if ($center == 1) {
  34.             $hc = int(($h / 2.6179) + 0.5);
  35.         };
  36.         $bit_bucket = $img->add_hguide($hc);
  37.         $bit_bucket = $img->add_vguide($vc);
  38.         gimp_drawable_update($layer, 0, 0, $w, $h);
  39.     };
  40. exit main;
  41.  
  42.